package own.stu.jobgib.playown.netty.assembly;


import io.netty.util.concurrent.FastThreadLocal;

public class FastThreadLocalTest {

    private static FastThreadLocal<Object> threadLocal0 = new FastThreadLocal<Object>() {
        @Override
        protected Object initialValue() {
            return new Object();
        }

        @Override
        protected void onRemoval(Object value) throws Exception {
            System.out.println("onRemoval");
        }
    };

    public static void main(String[] args) {


        new Thread(() -> {
            Object o = threadLocal0.get();
            System.out.println(o);
            threadLocal0.set(new Object());
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();

        new Thread(() -> {
            Object o = threadLocal0.get();
            System.out.println(o);
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
    }
}
